<template>
  <div class="d-flex justify-content-center mt-3">
    <div class="login  col-lg-6 col-12 bg-white pt-3">
        <form>
          <div class="input-group mb-3">
            <div class="input-group-prepend">
              <span class="input-group-text" >邮箱：</span>
            </div>
             <input type="text" class="form-control" v-model="qqEmail" placeholder="输入邮箱地址">
          </div>

          <div class="input-group mb-3">
            <div class="input-group-prepend">
              <span class="input-group-text" >密码：</span>
            </div>
             <input type="password" class="form-control" v-model="password" placeholder="你的密码">
          </div>

          <div class="input-group d-flex justify-content-center p-3">
              <button type="button" class="btn btn-primary" @click="login">登录</button>
             <button type="button" class="btn btn-primary mr-2" @click="toRegister">注册</button>

          </div>

        </form>
    </div>
  </div>
</template>

<script>
  import {mapMutations} from 'vuex';
 export default {
   data () {
     return {
      time:0,
      qqEmail:'',
      password:''
     }
   },
   components: {

   },
   methods:{
     ...mapMutations(['setLogin']),
     login(){
       this.$axios.post(this.$url+"login",{email:this.qqEmail,password:this.password}).then(res=>{
                 if(res.data.data.length>0){
                    this.$message({
                        type: 'info',
                        message: `登录成功`
                    });
                    this.setLogin(true);
                    this.$router.push({path:'/homePage'})
                 }
       })
     },
     toRegister(){
       this.$router.push({path:'/homePage/register'});
     }
   }
 }
</script>

<style scoped lang='less'>


</style>
